﻿module StepsTests


open System
open System.IO
open Microsoft.VisualStudio.TestTools.UnitTesting
open Streams
open Keywords
open Steps

[<TestClass>]
type StepsTests() = 

   [<TestMethod>]
   member public self.ReadInstructions_ReadsAllTokensUntilNextKeyword() =
      use stream = CreateStream("\"fluff\" and \"stuff\" When:")
      use reader = CreateReader(stream)

      let actual = ReadInstructions(reader)

      Assert.AreEqual(3, actual.Length)

   [<TestMethod>]
   member public self.ReadInstructions_PositionsReaderAtNextKeywordAfterReading() =
      use stream = CreateStream("\"fluff\" and \"stuff\" When:")
      use reader = CreateReader(stream)

      ReadInstructions(reader) |> ignore

      let actual = ReadKeyword(reader, Keyword.When).Value

      Assert.AreEqual("When:", actual.Source)


   [<TestMethod>]
   member public self.ReadInstructions_ReadsAllTokensUntilEof() =
      use stream = CreateStream("\"fluff\" and \"stuff\"")
      use reader = CreateReader(stream)

      let actual = ReadInstructions(reader)

      Assert.AreEqual(3, actual.Length)

